import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.util.Iterator;

/**
 * @author caiwl
 * @date 2020/7/20 17:21
 */
public class Ersao {
    public static void main(String[] args) {
        try {
            String dir = "C:\\Caiwl\\JetBrains\\IdeaProjects\\oschina\\wife\\src\\main\\resources\\68fc\\";
            Iterator<File> it = FileUtils.iterateFiles(new File(dir), new String[]{"json"}, false);
            while (it.hasNext()) {
                String json = FileUtils.readFileToString(it.next(), "UTF-8");
                JsonParser parser = new JsonParser();
                JsonObject data = parser.parse(json).getAsJsonObject();
                JsonArray rows = data.get("rows").getAsJsonArray();
                JsonObject row;
                for (int i = 0; i < rows.size(); i++) {
                    row = rows.get(i).getAsJsonObject();
                    System.out.println(row.get("num").getAsString() +
                            "," + row.get("EstateName").getAsString() +
                            ",'" + row.get("BuildNo").getAsString() +
                            "," + row.get("RoomNo").getAsString() +
                            "," + row.get("OwnerMobile").getAsString() +
                            "," + row.get("Floor").getAsString() +
                            "," + row.get("CountF").getAsString() +
                            "," + row.get("FX").getAsString() +
                            "," + row.get("Square").getAsString() +
                            "," + row.get("Price").getAsString() +
                            "," + row.get("RentPrice").getAsString() +
                            "," + row.get("PropertyDecoration").getAsString() +
                            "," + row.get("RegPerson").getAsString() +
                            "," + row.get("Remark").getAsString() +
                            "");
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
